home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / GX Libraries / GraphicsLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-31  |  2.2 KB  |  110 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        GraphicsLibrary.c
  4.  
  5.     Contains:    graphics libraries - general library routines 
  6.  
  7.     Written by:    Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Mike Reed, Oliver Steele, David Van Brink, Chris Yerga
  8.  
  9.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <1>      1/9/95    JD        First checked in.
  14. */
  15.  
  16.  
  17. #include <Memory.h>
  18. #include "GraphicsLibraries.h"
  19.  
  20. /*************/
  21. /* General routines */
  22. /*************/
  23.  
  24. void DisposeShapeAt(gxShape *oldShape)
  25. {
  26.     NilParamReturn(oldShape);
  27.     if (*oldShape) {
  28.         GXDisposeShape(*oldShape);
  29.         *oldShape = nil;
  30.     }
  31. }
  32.  
  33. void DisposeStyleAt(gxStyle   *oldStyle)
  34. {
  35.     NilParamReturn(oldStyle);
  36.     if (*oldStyle) {
  37.         GXDisposeStyle(*oldStyle);
  38.         *oldStyle = nil;
  39.     }
  40. }
  41.  
  42. void DisposeInkAt(gxInk *oldInk)
  43. {
  44.     NilParamReturn(oldInk);
  45.     if (*oldInk) {
  46.         GXDisposeInk(*oldInk);
  47.         *oldInk = nil;
  48.     }
  49. }
  50.  
  51. void DisposeTransformAt(gxTransform *oldTransform)
  52. {
  53.     NilParamReturn(oldTransform);
  54.     if (*oldTransform) {
  55.         GXDisposeTransform(*oldTransform);
  56.         *oldTransform = nil;
  57.     }
  58. }
  59.  
  60.  
  61. /****************/
  62. /* operations on shapes */
  63. /****************/
  64. static void GetSpaceMapping(gxViewPort port, gxViewDevice device, gxMapping *map)
  65. {
  66.     if (port)
  67.         GXGetViewPortGlobalMapping(port, map);
  68.     else
  69.         ResetMapping(map);
  70.  
  71.     if( device ) {
  72.         gxMapping temp;
  73.         MapMapping(map, GXGetViewDeviceMapping(device, &temp));
  74.     }
  75. }
  76.  
  77. void MapShapeToSpace(gxShape source, gxViewPort port, gxViewDevice device)
  78. {
  79.     gxMapping map;
  80.  
  81.     GetSpaceMapping(port, device, &map);
  82.     GXMapShape(source, &map);
  83. }
  84.  
  85. void MapShapeFromSpace(gxShape source, gxViewPort port, gxViewDevice device)
  86. {
  87.     gxMapping map;
  88.  
  89.     GetSpaceMapping(port, device, &map);
  90.     InvertMapping(&map, &map);
  91.     GXMapShape(source, &map);
  92. }
  93.  
  94. void MapPointToSpace(gxPoint *pt, gxViewPort port, gxViewDevice device)
  95. {
  96.     gxMapping map;
  97.  
  98.     GetSpaceMapping(port, device, &map);
  99.     MapPoints(&map, 1, pt);
  100. }
  101.  
  102. void MapPointFromSpace(gxPoint *pt, gxViewPort port, gxViewDevice device)
  103. {
  104.     gxMapping map;
  105.  
  106.     GetSpaceMapping(port, device, &map);
  107.     InvertMapping(&map, &map);
  108.     MapPoints(&map, 1, pt);
  109. }
  110.